import sys
from datetime import datetime

###------------------------
###Template for declaration(.h)
###------------------------
TPL_H_FRAME="""/**
 * @file %(fileName)s.h
 * @author 
 * @date %(gen_date)s
 * @brief declaration 
 */
#ifndef _T_%(macroName)s_H_
#define _T_%(macroName)s_H_


#endif /*_T_%(macroName)s_H_*/
"""

###---------------------------------
###Template for class implementation(.cpp)
###---------------------------------
TPL_CPP_FRAME="""/**
 * @file %(fileName)s.cpp
 * @author 
 * @date %(gen_date)s
 * @brief implementation for "%(fileName)s.h"
 */
#include "%(fileName)s.h"
#include "api.h"
#include "define.h"


"""



if __name__ == '__main__':
    if(len(sys.argv)<2):
        print "usage: %s input_file [output_dir]" % sys.argv[0]
        exit()
    fileName=sys.argv[1].lower()
    macroName=sys.argv[1].upper()
    output_dir = './output'
    if len(sys.argv)>=3 :
        output_dir = sys.argv[2]
    sOutPathH='%s/%s.h'%(output_dir,fileName)
    sOutPathCPP='%s/%s.cpp'%(output_dir,fileName)
    f_h = open(sOutPathH,'w')
    f_cpp = open(sOutPathCPP,'w')
    f_h.write(TPL_H_FRAME%{'gen_date':datetime.now().strftime('%Y-%m-%d'),
                           'fileName':fileName,
                           'macroName':macroName}
             )
    f_cpp.write(TPL_CPP_FRAME%{'gen_date':datetime.now().strftime('%Y-%m-%d'),
                               'fileName':fileName,
                               'macroName':macroName}
               )
    f_h.close()
    f_cpp.close()
